package jiangyeheng.second;

public class Main {
    public static void main(String[] args) {
        Worker worker = new Worker(5000, "张三", 3);
        Manager manager = new Manager(8000, "李四", 5);
        salCompute(worker);
        salCompute(manager);
    }

    private static void salCompute(Employee employee) {
        System.out.println(employee.getName()+"的工龄为"+employee.getWorkYears());
        System.out.println(employee.getName()+"的原来薪资为"+employee.getMoney());
        employee.addSalary();
        System.out.println(employee.getName()+"的薪资调整为"+employee.getMoney());
        employee.work();
        if(employee instanceof Worker) {
            Worker worker = (Worker) employee;
            worker.clock();
        } else if (employee instanceof Worker) {
            Manager manager=(Manager) employee;
            manager.meet();
        }
    }
}
interface SalaryCalculator{
    abstract void addSalary();
}
abstract class Employee implements SalaryCalculator{
    public String name;
    public double money;
    public int workYears;

    public double getMoney() {
        return money;
    }

    public String getName() {
        return name;
    }

    public int getWorkYears() {
        return workYears;
    }

    public Employee(double money, String name, int workYears) {
        this.money = money;
        this.name = name;
        this.workYears = workYears;
    }
    public abstract void work();


}
class Worker extends Employee{
    public Worker(double money, String name, int workYears) {
        super(money, name, workYears);
    }

    @Override
    public void addSalary() {
        this.money=this.money*1.1+this.workYears*100;
    }

    @Override
    public void work() {
        System.out.println(name+"正在工作");
    }

    public void clock(){
        System.out.println(name+"已打卡");
    }

}

class Manager extends Employee{
    public Manager(double money, String name, int workYears) {
        super(money, name, workYears);
    }

    @Override
    public void addSalary() {
        this.money=this.money*1.2+this.workYears*200;
    }

    @Override
    public void work() {
        System.out.println(name+"正在巡查工厂");
    }

    public void meet(){
        System.out.println(name+"正在开会");
    }
}